import { _decorator, AssetManager, Component, director, Node, ProgressBar } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('loadding')
export class loadding extends Component {
    private isLoaded = false;
    @property(ProgressBar)
    loadProgress: ProgressBar = null;
    onLoad() {
        this.init();
    }

    init() {

        this.startJindu();
    }
    startJindu() {
        // 将在 10 秒后开始计时，每 5 秒执行一次回调，重复 3 + 1 次
        this.schedule(function () {
            // 这里的 this 指向 component
            this.loadProgress.progress += 0.1;
            if (this.loadProgress.progress >= 0.5) {
                this.unschedule(this.schedule)
                this.jinduPause()
            }
        }, 0.06, 4, 0.2);
    }
    jinduPause() {
        this.scheduleOnce(() => {
            this.loadScene()
        }, 1)
    }
    loadScene() {
        this.schedule(function () {
            this.loadProgress.progress += 0.1;
            if (this.loadProgress.progress >= 1) {
                this.unschedule(this.schedule);
                director.loadScene("main");
            }
        }, 0.1, 5, 0.2)
    }
}

